package com.lap.auth.adapter.driven.web.authorization;

import com.lap.auth.application.authorization.AuthorQueryService;
import com.lap.auth.application.authorization.dto.MenuViewDto;
import com.lap.auth.application.authorization.dto.PermissionDto;
import com.lap.auth.application.authorization.dto.UserInfoDto;
import com.lap.framework.common.annotation.AuthSkip;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "用户授权", description = "提供用户获取当前登录人信息，当前用户菜单获取，当前权限获取")
@RequiredArgsConstructor
@RestController
@RequestMapping("api/v1/authorization")
public class AuthorizationController {

  private final AuthorQueryService authorQueryService;

  // 当前版本不需要该方法
  @Operation(summary = "获取当前用户信息")
  @AuthSkip
  @GetMapping("userinfo")
  public UserInfoDto getUserInfo() {
    return authorQueryService.getUserInfo();
  }

  @Operation(summary = "获取当前用户菜单")
  @AuthSkip
  @GetMapping("menus")
  public List<MenuViewDto> getMenus() {
    return authorQueryService.getMenus();
  }

  @Operation(summary = "获取当前用户权限")
  @GetMapping("permission")
  public PermissionDto getPermission() {
    return authorQueryService.getPermission();
  }
}
